<div class="widget">
  <div class="box">
    <h3>Status Report</h3>
    <div id="boxContent">
    	<?php
		$wins = 0;
		$loses = 0;
		$ties = 0;
		
		$sql = "SELECT * FROM `schedules` WHERE (`home_school_id` = :id OR `away_school_id` = :away) and `sport_id` = :sport";
		$q = db::Query($sql, array(':sport'=>$_SESSION['team'], ':away'=>$SCHOOL['school_id'], ':id'=>$SCHOOL['school_id']));
		while($row = $q->fetch()){
			$sql = "SELECT * FROM `game_result` WHERE `schedule_id` = :id";
			$q2 = db::Query($sql, array(':id'=>$row['schedule_id']));
			$r = $q2->fetch();
			if($r['total_home_score'] == $r['total_away_score']){
				$ties ++;
			}elseif($r['total_home_score'] > $r['total_away_score'] and $row['home_school_id'] == $SCHOOL['school_id']){
				$wins ++;
			}elseif($r['total_home_score'] < $r['total_away_score'] and $row['away_school_id'] == $SCHOOL['school_id']){
				$wins ++;
			}else{
				$loses ++;
			}
		}
		?>
    	<center><strong style="font-size:14px">Team Record</strong></center><br/>
        <table style="margin-left:auto; margin-right:auto">
        	<tr>
            <td>
        	<div style="border:#333 1px solid; float:left; padding:5px; background-color:#999; font-weight:bold; color:#FFF; width:45px; margin-right:5px;" align="center">
        		<?php echo $wins ?><br/>Wins
        	</div>
        	<div style="border:#333 1px solid; float:left; padding:5px; background-color:#999; font-weight:bold; color:#FFF; width:45px; margin-right:5px;" align="center">
        		<?php echo $loses ?><br/>Loses
        	</div>
        	<div style="border:#333 1px solid; float:left; padding:5px; background-color:#999; font-weight:bold; color:#FFF; width:45px;" align="center">
        		<?php echo $ties ?><br/>Ties
        	</div>
            </td>
            </tr>
        </table><br/><br/>
        <center><strong style="font-size:14px">Next Game/Event</strong></center><br/>
        <center>No Game/Event Data Found</center>
        <br/><br/>
        <center><strong style="font-size:14px">Last Game/Event</strong></center><br/>
        <center>No Game/Event Data Found</center>
    </div>
  </div>
</div>